/*
 *  Copyright 2007 Blandware (http://www.blandware.com)
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */
package com.blandware.atleap.persistence.core;

import com.blandware.atleap.model.core.TileContainer;
import com.blandware.atleap.model.core.Layout;
import com.blandware.atleap.common.util.PartialCollection;
import com.blandware.atleap.common.util.QueryInfo;

import java.util.List;

/**
 * <p>DAO for tile containers.</p>
 * <p><a href="TileContainerDAO.java.html"><i>View source</i></a></p>
 *
 * @author Roman Puchkovskiy <a href="mailto:roman.puchkovskiy@blandware.com">
 *         &lt;roman.puchkovskiy@blandware.com&gt;</a>
 * @version $Revision: 1.2 $ $Date: 2007/04/08 15:07:13 $
 */
public interface TileContainerDAO extends DAO {

    // ~ CRUD Methods ================================================================

    /**
     * Creates new container.
     *
     * @param container Value object that represents what container must be
     * created
     * @param layout layout to which to assign container
     * @return ID of created container
     */
    public Long createTileContainer(TileContainer container, Layout layout);

    /**
     * Retrieves container with specified identifier.
     *
     * @param id ID of container
     * @return TileContainer or null if no container with specified ID exists in
     * database
     */
    public TileContainer retrieveTileContainer(Long id);

	/**
	 * Updates title container.
	 *
	 * @param tileContainer container to update
	 */
	public void updateTileContainer(TileContainer tileContainer);

    /**
     * Deletes container.
     *
     * @param container container to delete
     */
    public void deleteTileContainer(TileContainer container);

    // ~ Additional methods ================================================================

    /**
     * Retrieves filtered/sorted collection of containers.
     *
     * @param queryInfo Object that contains information about how to filter
     * and sort data
     * @return Collection of containers
     */
    public PartialCollection listTileContainers(QueryInfo queryInfo);

	/**
	 * Searches for duplicates. Returns true if there is one or more tile
     * containers with another ID, but which have same definition and list
     * names and is placed on same layout.
	 *
	 * @param tileContainer container to find duplicates for
	 * @return whether this container has duplicates
	 */
	public boolean hasDuplicates(TileContainer tileContainer);

    // ~ Finders ================================================================

    /**
     * Returns a list of containers which belong to layout with a given ID.
     *
     * @param layoutId ID of layout to search by
     * @return list of containers
     */
    public List findTileContainersByLayoutId(Long layoutId);

    /**
     * Returns a container which belongs to layout with a given ID and has
     * given full identifier.
     *
     * @param layoutId ID of layout to search by
     * @param identifier full identifier to search by
     * @return tile container or null if not found
     */
    public TileContainer findTileContainerByLayoutIdAndIdentifier(Long layoutId,
            String identifier);
}
